GTBK_turtle_measures <- GTBK_data %>%
select(fecha, nombre_tortuga, marca_nombre, especie_nombre_latino, numero_recaptura, a_c_c,, l_c_c, lugar, geografía, sexo_correcto)
write_csv(GTBK_turtle_measures, file = ("data/GTBK_turtle_measures.csv"))
write_csv(GTBK_data, file = ("data/GTBK_data.csv"))
GTBK_data %>%
group_by(especie_nombre_latino) %>%
count()
## # A tibble: 5 × 2
## # Groups: especie_nombre_latino [5]
## especie_nombre_latino n
## <chr> <int>
## 1 Caretta caretta 2
## 2 Chelonia mydas 848
## 3 Eretmochelys imbricata 7
## 4 Lepidochelys olivacea 15
## 5 <NA> 8
buis_2022 %>%
mutate(species = case_when(
sp == "HB" ~ "Eretmochelys imbricata",
sp == "GR" ~ "Chelonia mydas")
) %>%
ggplot(aes(x = species, y = cclnuct, fill = species)) +
geom_violin() +
scale_fill_manual(values = c("chartreuse4", "hotpink4")) +
theme_minimal() +
coord_flip () +
labs(title = "Average Curved Carapace Length of Green and Hawksbill Sea Turtles",
subtitle = "Reproductive Females Measured During 2022 Nesting Season on Buck Island, USVI",
x = "Species",
y = "Curved Carapace Length (cm)",
fill = "Species")
## Warning: Removed 10 rows containing non-finite values (`stat_ydensity()`).
buis_2022 %>%
mutate(species = case_when(
sp == "HB" ~ "Eretmochelys imbricata",
sp == "GR" ~ "Chelonia mydas")
) %>%
ggplot(aes(x = species, y = cclnuct, fill = species)) +
geom_boxplot() +
scale_fill_manual(values = c("chartreuse4", "hotpink4")) +
theme_minimal() +
coord_flip () +
labs(title = "Average Curved Carapace Length of Green and Hawksbill Sea Turtles",
subtitle = "Reproductive Females Measured During 2022 Nesting Season on Buck Island, USVI",
x = "Species",
y = "Curved Carapace Length (cm)",
fill = "Species")
## Warning: Removed 10 rows containing non-finite values (`stat_boxplot()`).
GTBK_data %>%
filter(especie_nombre_latino == "Chelonia mydas" |
especie_nombre_latino == "Eretmochelys imbricata" |
especie_nombre_latino == "Lepidochelys olivacea" |
especie_nombre_latino == "Caretta caretta") %>%
ggplot(aes(x = especie_nombre_latino, y = a_c_c, fill = especie_nombre_latino)) +
geom_boxplot() +
scale_fill_manual(values = c("goldenrod1","chartreuse4", "hotpink4","cornflowerblue")) +
theme_minimal() +
coord_flip() +
facet_wrap(~ geografía) +
labs(title = "Curved Carapace Length Measurements of Four Sea Turtle Species",
subtitle = "Monitored by GTBK in Kino Bay, Mexico between 2010-2023",
x = "Species",
y = "Curved Carapace Length (cm)",
fill = "Species")
## Warning: Removed 1 rows containing non-finite values (`stat_boxplot()`).
GTBK_data %>%
filter(numero_recaptura %in% c(2, 3, 4)) %>%
ggplot(aes(x = numero_recaptura)) +
geom_bar()
GTBK_data %>%
filter(numero_recaptura %in% c(2, 3, 4)) %>%
ggplot(aes(x = numero_recaptura, fill = sexo_correcto)) +
geom_bar()
GTBK_data %>%
filter(numero_recaptura %in% c(1, 2, 3, 4)) %>%
filter(especie_nombre_latino == "Chelonia mydas" |
especie_nombre_latino == "Eretmochelys imbricata" |
especie_nombre_latino == "Caretta caretta" |
especie_nombre_latino == "Lepidochelys olivacea") %>%
mutate(especie_nombre_latino = factor(especie_nombre_latino, levels = c("Chelonia mydas", "Lepidochelys olivacea", "Eretmochelys imbricata", "Caretta caretta"))) %>%
ggplot(aes(x = numero_recaptura, fill = especie_nombre_latino)) +
geom_bar() +
scale_fill_manual(values = c("palegreen3", "gold", "darkorchid4", "darkturquoise")) +
theme_minimal() +
labs(title = "Number of Sea Turtle Captures by GTBK",
subtitle = "Of Four Sea Turtle Species in Kino Bay, Mexico",
x = "Number of Times Captured",
y = "Number of Turtles",
fill = "Species")
ggsave("final_visualizations/GTBKcapturesbyspecies.jpg", device = "jpg", dpi = 500)
## Saving 7 x 5 in image
recapture_tibble <- GTBK_data %>%
group_by(marca_nombre) %>%
select(nombre_tortuga, fecha, especie, area_de_monitoreo, marca_nombre)
recapture_tibble %>%
group_by(marca_nombre) %>%
summarize(marca_nombre)
## Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
## dplyr 1.1.0.
## ℹ Please use `reframe()` instead.
## ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
## always returns an ungrouped data frame and adjust accordingly.
## `summarise()` has grouped output by 'marca_nombre'. You can override using the
## `.groups` argument.
## # A tibble: 880 × 1
## # Groups: marca_nombre [767]
## marca_nombre
## <chr>
## 1 ""
## 2 ""
## 3 ""
## 4 ""
## 5 ""
## 6 ""
## 7 ""
## 8 "G 12227"
## 9 "GT 17841"
## 10 "GT 0977"
## # … with 870 more rows
GTBK_data %>%
group_by(especie_nombre_latino) %>%
count (sexo_correcto)
## # A tibble: 9 × 3
## # Groups: especie_nombre_latino [5]
## especie_nombre_latino sexo_correcto n
## <chr> <chr> <int>
## 1 Caretta caretta Indefinido 2
## 2 Chelonia mydas Hembra 339
## 3 Chelonia mydas Indefinido 483
## 4 Chelonia mydas Macho 26
## 5 Eretmochelys imbricata Indefinido 7
## 6 Lepidochelys olivacea Hembra 10
## 7 Lepidochelys olivacea Indefinido 1
## 8 Lepidochelys olivacea Macho 4
## 9 <NA> <NA> 8
# GTBK_2018_2023 %>%
# group_by(especie_nombre_latino) %>%
# count(Sexo)
# GTBK_2010_2018 %>%
# group_by(Especie) %>%
# count(Sexo)
buis_2022 %>%
group_by(sp) %>%
count(sex)
## # A tibble: 2 × 3
## # Groups: sp [2]
## sp sex n
## <chr> <chr> <int>
## 1 GR female 27
## 2 HB female 29
GTBK_data %>%
filter(numero_recaptura == 1) %>%
group_by(especie_nombre_latino) %>%
count (sexo_correcto)
## # A tibble: 9 × 3
## # Groups: especie_nombre_latino [5]
## especie_nombre_latino sexo_correcto n
## <chr> <chr> <int>
## 1 Caretta caretta Indefinido 2
## 2 Chelonia mydas Hembra 248
## 3 Chelonia mydas Indefinido 380
## 4 Chelonia mydas Macho 23
## 5 Eretmochelys imbricata Indefinido 7
## 6 Lepidochelys olivacea Hembra 10
## 7 Lepidochelys olivacea Indefinido 1
## 8 Lepidochelys olivacea Macho 4
## 9 <NA> <NA> 1
GTBK_data %>%
filter(especie_nombre_latino != "NA") %>%
filter(numero_recaptura == 1) %>%
ggplot(aes(x = sexo_correcto,
fill = sexo_correcto)) +
geom_bar() +
facet_wrap( ~ especie_nombre_latino,
# <- fct_relevel(especie_nombre_latino,
# "Caretta caretta",
# "Eretmochelys imbricata",
# "Lepidochelys olivacea",
# "Chelonia mydas"),
scales = "free_y") +
labs(title = "Species and Sex Distribution",
subtitle = "of turtles captured in Kino Bay",
x = "sex",
y = "number of individuals",
fill = "sex") +
scale_fill_manual(values = c("#cd4071","#feca8d", "#721f81", "#000004"))
# naniar::gg_miss_var(GTBK_data)
visdat::vis_miss(GTBK_data)
## Warning: Raster pixels are placed at uneven horizontal intervals and will be shifted
## ℹ Consider using `geom_tile()` instead.
ggsave("final_visualizations/missingdata.jpg", device = "jpg", dpi = 500)
## Saving 7 x 5 in image
## Warning: Raster pixels are placed at uneven horizontal intervals and will be shifted
## ℹ Consider using `geom_tile()` instead.
# visdat::vis_miss(GTBK_2018_2023)
880 times went out total, 188 instances of recapture
GTBK_data <- GTBK_data %>%
mutate(año = year(fecha)) %>%
mutate(mes = month(fecha)) %>%
mutate(mes_nombre = case_when(
mes == "1" ~ "jan",
mes == "2" ~ "feb",
mes == "3" ~ "mar",
mes == "4" ~ "apr",
mes == "5" ~ "may",
mes == "6" ~ "jun",
mes == "7" ~ "jul",
mes == "8" ~ "aug",
mes == "9" ~ "sep",
mes == "10" ~ "oct",
mes == "11" ~ "nov",
mes == "12" ~ "dec"))
as.integer(GTBK_data$mes)
## [1] 10 10 10 10 3 3 3 10 5 10 6 6 6 6 6 6 6 9 9 9 10 3 3 4 4
## [26] 4 4 4 6 6 5 12 7 7 10 10 11 11 11 11 12 12 11 11 11 11 2 2 2 3
## [51] 3 3 3 3 3 3 3 3 3 4 4 4 11 11 11 5 5 5 5 6 6 6 6 6 6
## [76] 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8
## [101] 8 8 8 8 8 8 8 9 9 9 9 5 10 10 10 10 10 10 1 1 1 1 1 3 3
## [126] 3 3 3 3 3 3 11 11 11 11 11 11 5 12 1 1 1 9 2 4 4 4 4 4 4
## [151] 4 5 5 5 5 5 5 5 5 3 11 11 11 11 11 12 12 12 12 12 12 12 12 12 11
## [176] 11 12 12 12 12 12 12 11 11 11 11 12 12 12 12 12 12 12 8 9 9 9 9 10 10
## [201] 10 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 9 9 10 10 5 5 5
## [226] 5 6 6 6 6 6 6 6 6 6 6 5 5 6 6 6 6 6 6 12 12 12 12 12 1
## [251] 1 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4
## [276] 4 4 2 2 2 2 4 4 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6
## [301] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 7 7 7 7
## [326] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1 1 1 8 8 8
## [351] 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 6 10 10 10 10 10 10 10
## [376] 10 10 10 11 11 11 11 11 2 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4
## [401] 6 6 6 6 6 6 6 6 NA 10 5 5 5 5 5 5 5 5 5 5 5 5 6 7 7
## [426] 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 9 10 NA 10 10 10
## [451] 10 10 10 10 10 10 10 10 10 10 10 11 11 12 12 12 12 2 2 3 3 3 3 3 3
## [476] 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
## [501] 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7
## [526] 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9
## [551] 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10
## [576] 10 10 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 2 2 2
## [601] 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 5 5 5 5 5 5 5 5 5
## [626] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 NA 6 6 6 6
## [651] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7
## [676] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 9 9 9 9 9
## [701] 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11
## [726] 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 2
## [751] 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
## [776] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
## [801] 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
## [826] 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8
## [851] 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 11 11 11 11
## [876] 11 11 11 11 11
as.integer(GTBK_data$año)
## [1] 2010 2010 2010 2010 2011 2011 2011 2012 2012 2013 2013 2013 2013 2013 2013
## [16] 2013 2013 2013 2013 2013 2013 2014 2014 2014 2014 2014 2014 2014 2014 2014
## [31] 2014 2014 2014 2014 2014 2014 2014 2014 2014 2014 2014 2014 2015 2015 2015
## [46] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [61] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [76] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [91] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [106] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [121] 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 2015
## [136] 2015 2015 2015 2015 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [151] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [166] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [181] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [196] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [211] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [226] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
## [241] 2016 2016 2016 2016 2016 2016 2016 2016 2016 2017 2017 2017 2017 2017 2017
## [256] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [271] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [286] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [301] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [316] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [331] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [346] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [361] 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 2017
## [376] 2017 2017 2017 2017 2017 2017 2017 2017 2018 2018 2018 2018 2018 2018 2018
## [391] 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018
## [406] 2018 2018 2018 NA 2018 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019
## [421] 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019
## [436] 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 NA 2019 2019 2019
## [451] 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019
## [466] 2019 2019 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [481] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [496] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [511] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [526] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [541] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [556] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [571] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020
## [586] 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 2021 2021 2021
## [601] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [616] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [631] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [646] NA 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [661] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [676] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [691] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [706] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [721] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021
## [736] 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 2022
## [751] 2023 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [766] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [781] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [796] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [811] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [826] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [841] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [856] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
## [871] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
GTBK_outings <- GTBK_data %>%
group_by(mes) %>%
count(mes)
GTBK_recapturas <- GTBK_data %>%
filter(numero_recaptura %in% c(2, 3, 4)) %>%
group_by(mes) %>%
count(mes)
as.integer(GTBK_outings$mes)
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 NA
as.integer(GTBK_recapturas$mes)
## [1] 1 2 3 4 5 6 7 8 9 10 11 12
full_join(GTBK_outings, GTBK_recapturas, by = "mes") %>%
mutate(tortugas_por_esfuerzo = n.y/n.x) %>%
select(mes, tortugas_por_esfuerzo) %>%
mutate(mes = case_when(
mes == "1" ~ "jan",
mes == "2" ~ "feb",
mes == "3" ~ "mar",
mes == "4" ~ "apr",
mes == "5" ~ "may",
mes == "6" ~ "jun",
mes == "7" ~ "jul",
mes == "8" ~ "aug",
mes == "9" ~ "sep",
mes == "10" ~ "oct",
mes == "11" ~ "nov",
mes == "12" ~ "dec"
)) %>%
mutate(
mes = factor(mes, levels = c(
"jan",
"feb",
"mar",
"apr",
"may",
"jun",
"jul",
"aug",
"sep",
"oct",
"nov",
"dec"
)
)
) %>%
drop_na() %>%
ggplot(aes(x = mes, y = tortugas_por_esfuerzo)) +
geom_col(fill = "seagreen4") +
labs(title = "Seasonality of Sea Turtle Recaptures by GTBK",
subtitle = "Per Effort Hour",
x = "Month",
y = "Turtle Per Effort Hour")
ggsave("final_visualizations/seasonality_of_recaptures.jpg", device = "jpg", dpi = 500)
## Saving 7 x 5 in image
# install.packages("ggalluvial")
library(ggalluvial)
Sankey <- GTBK_data %>%
filter(numero_recaptura %in% c(3,4)) %>%
mutate(yearmonth = paste(año, mes, sep = "-")) %>%
select(marca_nombre, año) %>%
group_by(marca_nombre, año) %>%
summarize(n = n()) %>%
arrange(año) #%>%
## `summarise()` has grouped output by 'marca_nombre'. You can override using the
## `.groups` argument.
# pivot_wider(
# names_from = año,
# values_from = n
# )
#
# Sankey <- replace(Sankey,is.na(Sankey),0) %>%
# mutate(frequency = n())
Sankey %>%
ggplot(
aes(
y = n,
axis1 = marca_nombre,
axis2 = año
)
) +
geom_alluvium(aes(fill = marca_nombre)) +
geom_stratum(width = 1/12, fill = "black", color = "grey") +
geom_label(stat = "stratum", aes(label = after_stat(stratum))) +
scale_fill_viridis_d()
#scale_x_discrete(limits = c("GT 1569", "GT 3843", "GT 3845", "GT 5297", "GT 8120", "GT 8187", "GT 11489", "GT 12261", "GT 15826"))
# library(ggalluvial)
#
# GTBK_data %>%
# filter(numero_recaptura %in% c(3,4)) %>%
# mutate(yearmonth = paste(año, mes, sep = "-")) %>%
# select(marca_nombre, año) %>%
# group_by(marca_nombre) %>%
# pivot_wider(
# names_from = año,
# values_from = count(GTBK_data$año)) %>%
# ggplot(
# aes(y = marca_nombre, axis1 = 2014, axis2 = 2015, axis3 = 2016, axis4 = 2017, axis5 = 2018, axis6 = 2019, axis7 = 2020, axis8 = 2021, axis9 = 2022)) +
# geom_alluvium()
tortugas_por_tiempo <- GTBK_data %>% #counting every time they caught a turtle
filter(numero_recaptura %in% c(1, 2, 3, 4)) %>%
group_by(fecha, mes, año) %>%
drop_na(marca_nombre) %>%
summarize(turtles = n()) %>%
group_by(mes, año) %>%
summarize(total_turtles = sum(turtles, na.rm = T))
## `summarise()` has grouped output by 'fecha', 'mes'. You can override using the
## `.groups` argument.
## `summarise()` has grouped output by 'mes'. You can override using the `.groups`
## argument.
#
# tiempo <- GTBK_data %>% # of times they went out
# distinct(fecha, mes, año) %>%
# group_by(mes, año) %>%
# summarize(effort = n())
#
# full_join(tiempo, tortugas_por_tiempo, by = c("mes", "año"))
library(lubridate)
tortugas_por_tiempo <- GTBK_data %>% #counting every time they caught a turtle
filter(numero_recaptura %in% c(1, 2, 3, 4)) %>%
group_by(fecha, mes, año) %>%
drop_na(marca_nombre) %>%
summarize(turtles = n()) %>%
group_by(mes, año) %>%
summarize(total_turtles = sum(turtles, na.rm = T))
## `summarise()` has grouped output by 'fecha', 'mes'. You can override using the
## `.groups` argument.
## `summarise()` has grouped output by 'mes'. You can override using the `.groups`
## argument.
tiempo <- GTBK_data %>% # of times they went out
distinct(fecha, mes, año) %>%
group_by(fecha, mes, año) %>%
summarize(effort = n())
## `summarise()` has grouped output by 'fecha', 'mes'. You can override using the
## `.groups` argument.
Capturas_y_ezfuerzo <- full_join(tiempo, tortugas_por_tiempo, by = c("mes", "año")) %>%
mutate(tortugas_por_esfuerzo = effort/total_turtles) %>%
mutate(year_month = ym(paste(año, mes, sep = "-")))
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `year_month = ym(paste(año, mes, sep = "-"))`.
## ℹ In group 218: `fecha = NA`, `mes = NA`.
## Caused by warning:
## ! All formats failed to parse. No formats found.
Capturas_y_ezfuerzo %>%
ggplot(
aes(x = year_month,
y = tortugas_por_esfuerzo
)
) +
geom_col()
## Warning: Removed 4 rows containing missing values (`position_stack()`).
ggsave("final_visualizations/captures_per_effort_over_time.jpg", device = "jpg", dpi = 500)
## Saving 7 x 5 in image
## Warning: Removed 4 rows containing missing values (`position_stack()`).
GTBK_data %>%
mutate(yearmonth = ym(paste(año, mes, sep = "-")))
## Warning: There were 3 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `yearmonth = ym(paste(año, mes, sep = "-"))`.
## ℹ In group 1: `marca_nombre = ""`.
## Caused by warning:
## ! 1 failed to parse.
## ℹ Run ]8;;ide:run:dplyr::last_dplyr_warnings()dplyr::last_dplyr_warnings()]8;; to see the 2 remaining warnings.
## # A tibble: 880 × 40
## # Groups: marca_nombre [767]
## nombre_to…¹ estac…² fecha area_…³ posic…⁴ hora_…⁵ especie peso
## <chr> <chr> <dttm> <chr> <chr> <chr> <chr> <dbl>
## 1 Lencho <NA> 2010-10-11 00:00:00 ISPM N28º37… 0.1458… Chelon… 15
## 2 Lili <NA> 2010-10-12 00:00:00 ISPM N28º37… <NA> Chelon… 18
## 3 Alejandra … <NA> 2010-10-12 00:00:00 ISPM <NA> <NA> Chelon… 17.5
## 4 Ana Luisa <NA> 2010-10-12 00:00:00 ISPM N28º22… <NA> Chelon… 27
## 5 Naomi Primav… 2011-03-15 00:00:00 ISPM N28371… <NA> Chelon… 19
## 6 Romelia Primav… 2011-03-16 00:00:00 ISPM N28371… <NA> Chelon… 17.6
## 7 LORAYNE Primav… 2011-03-16 00:00:00 ISPM n28221… <NA> Chelon… 21.6
## 8 profepa Verano 2012-10-08 00:00:00 choyud… <NA> <NA> Eretmo… 4
## 9 prescolina Otono 2012-05-11 00:00:00 Alcalt… N23.83… 0.5124… Chelon… 32
## 10 PAPIRINGO Invier… 2013-10-01 00:00:00 Pta. B… N28.78… 0.5277… Chelon… 42.8
## # … with 870 more rows, 32 more variables: sexo <chr>, l_r_c <dbl>,
## # l_c_c <dbl>, a_r_c <dbl>, a_c_c <dbl>, p_c <dbl>, l_p <dbl>, l_t_c <dbl>,
## # marca_nombre <chr>, marca_izquierda <chr>, fecha_inicio <dttm>,
## # hora_inicio <dbl>, hora_fin <dbl>, total_horas <dbl>, tipo_monitoreo <chr>,
## # metodologia <chr>, latitud <dbl>, longitud <dbl>,
## # unidad_utm_o_grados <chr>, hora_captura <dbl>, material_marcas <chr>,
## # marca_previa_izquierda <chr>, comentarios <chr>, …
tortugas_por_tiempo <- GTBK_data %>% #counting every time they caught a turtle
filter(numero_recaptura %in% c(1, 2, 3, 4)) %>%
group_by(fecha, mes_nombre, año) %>%
drop_na(marca_nombre) %>%
summarize(turtles = n()) %>%
group_by(mes_nombre, año) %>%
summarize(total_turtles = sum(turtles, na.rm = T))
## `summarise()` has grouped output by 'fecha', 'mes_nombre'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'mes_nombre'. You can override using the
## `.groups` argument.
tiempo <- GTBK_data %>% # of times they went out
distinct(fecha, mes_nombre, año) %>%
group_by(mes_nombre, año) %>%
summarize(effort = n())
## `summarise()` has grouped output by 'mes_nombre'. You can override using the
## `.groups` argument.
tortugas_por_esfuerzo <- full_join(tortugas_por_tiempo, tiempo) %>%
mutate(esfuerzo = total_turtles/effort) %>%
drop_na()
## Joining with `by = join_by(mes_nombre, año)`
as.integer(tortugas_por_esfuerzo$mes)
## Warning: Unknown or uninitialised column: `mes`.
## integer(0)
as.integer(tortugas_por_esfuerzo$año)
## [1] 2014 2015 2016 2017 2018 2020 2021 2022 2015 2016 2017 2019 2020 2021 2022
## [16] 2014 2015 2016 2019 2020 2021 2015 2016 2017 2018 2020 2021 2023 2015 2016
## [31] 2017 2014 2015 2016 2017 2019 2020 2021 2022 2013 2014 2015 2016 2017 2018
## [46] 2019 2020 2021 2022 2014 2015 2016 2017 2018 2020 2021 2022 2012 2014 2015
## [61] 2016 2017 2019 2020 2021 2022 2014 2015 2016 2017 2019 2020 2021 2022 2010
## [76] 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2013 2015 2016 2017
## [91] 2019 2020 2021 2022
tortugas_por_esfuerzo %>%
mutate(mes_nombre = factor(mes_nombre, levels = c("jan", "feb", "mar", "apr","may","jun","jul","aug","sep","oct","nov","dec"))) %>%
drop_na() %>%
ggplot(aes(x = mes_nombre, y = año, fill = esfuerzo)) +
geom_tile() +
# geom_text(aes(label = round(esfuerzo, 2))) +
labs(title = "Turtle captures",
subtitle = "represented by effort over year and month",
x = "month",
y = "year",
fill = "turtles per effort") +
scale_fill_gradient(low = "yellow", high = "cyan4") +
# limits = c(0,NA)) +
coord_fixed(ratio = 1) +
scale_y_continuous(breaks = c(2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023)) +
theme_bw()
ggsave("final_visualizations/heat_map.jpg", device = "jpg", dpi = 500)
## Saving 7 x 5 in image
lugar_de_tortugas <- GTBK_data %>%
mutate(mes = month(fecha)) %>%
mutate(año = year(fecha)) %>%
select(marca_nombre, lugar, geografía, numero_recaptura, mes, año, especie_nombre_latino)
# overview graph
lugar_de_tortugas %>%
drop_na() %>%
ggplot(aes(x = año, fill = geografía)) +
geom_bar() +
labs(title = "Spacial Overview",
subtitle = "Turtles Captured by Location",
x = "year", y = "turtles captured",
fill = "geography") +
scale_x_continuous(breaks = c(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023)) +
scale_fill_manual(values = c("cyan4", "cyan2", "coral1")) +
theme_bw()
#facet graph
lugar_de_tortugas %>%
drop_na() %>%
ggplot(aes(x = año, fill = especie_nombre_latino)) +
geom_bar() +
facet_grid( ~ geografía) +
labs(title = "Spacial Overview",
subtitle = "Turtles Captured by Location",
x = "year", y = "turtles captured",
fill = "geography") +
scale_fill_manual(values = c("gold", "darkseagreen3", "mediumorchid", "darkolivegreen")) +
theme_bw()
#isla graph
lugar_de_tortugas %>%
filter(geografía == "isla") %>%
drop_na() %>%
ggplot(aes(x = año, fill = especie_nombre_latino)) +
geom_bar() +
labs(title = "Species Distribution on the Islands",
x = "year", y = "number of turtles",
fill = "species") +
scale_x_continuous(breaks = c(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023)) +
scale_fill_manual(values = c("gold", "darkseagreen3", "mediumorchid", "darkolivegreen"))+
theme_bw()
#estuario graph
lugar_de_tortugas %>%
filter(geografía == "estuario") %>%
drop_na() %>%
ggplot(aes(x = año, fill = especie_nombre_latino)) +
geom_bar() +
labs(title = "Species Distribution in the Estuaries",
x = "year", y = "number of turtles",
fill = "species") +
scale_x_continuous(breaks = c(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023))+
scale_fill_manual(values = c("gold", "darkseagreen3", "mediumorchid", "darkolivegreen"))+
theme_bw()
A Green sea turtle hatchling headed toward the sea.
A Hawksbill sea turtle laying her nest on Buck Island.